package com.rppowell.pixie.swing.sprite;

import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.border.Border;

import com.rppowell.pixie.models.Sprite;

@SuppressWarnings("rawtypes")
public class SpriteComboBoxRenderer extends JLabel implements ListCellRenderer {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static final Border raisedborder = BorderFactory.createRaisedBevelBorder();
	static final Border loweredborder = BorderFactory.createLoweredBevelBorder();

	@Override
	public Component getListCellRendererComponent(JList l,
			Object o, int index, boolean isSelected, boolean hasFocus) {
		if (isSelected) {
			setBorder(loweredborder);
		} else {
			setBorder(raisedborder);
		}
		if (hasFocus) {
			setBackground(l.getSelectionBackground());
			setForeground(l.getSelectionForeground());
		} else {
			setBackground(l.getBackground());
			setForeground(l.getForeground());
			
		}
		Sprite s = (Sprite)o;
		ImageIcon icon = new ImageIcon(s);
		setIcon(icon);
		return this;
	}

}